package com.ruoyi.park.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.park.domain.WLogisticsParkInfo;
import com.ruoyi.park.service.IWLogisticsParkInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 园区信息Controller
 * 
 * @author wzy
 * @date 2024-09-01 18:33:13
 */
@RestController
@RequestMapping("/parks/park")
public class WLogisticsParkInfoController extends BaseController
{
    @Autowired
    private IWLogisticsParkInfoService wLogisticsParkInfoService;

    /**
     * 查询园区信息列表
     */
    @PreAuthorize("@ss.hasPermi('parks:park:list')")
    @GetMapping("/list")
    public TableDataInfo list(WLogisticsParkInfo wLogisticsParkInfo)
    {
        startPage();
        List<WLogisticsParkInfo> list = wLogisticsParkInfoService.selectWLogisticsParkInfoList(wLogisticsParkInfo);
        return getDataTable(list);
    }

    /**
     * 导出园区信息列表
     */
    @PreAuthorize("@ss.hasPermi('parks:park:export')")
    @Log(title = "园区信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WLogisticsParkInfo wLogisticsParkInfo)
    {
        List<WLogisticsParkInfo> list = wLogisticsParkInfoService.selectWLogisticsParkInfoList(wLogisticsParkInfo);
        ExcelUtil<WLogisticsParkInfo> util = new ExcelUtil<WLogisticsParkInfo>(WLogisticsParkInfo.class);
        util.exportExcel(response, list, "园区信息数据");
    }

    /**
     * 获取园区信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('parks:park:query')")
    @GetMapping(value = "/{logisticsParkId}")
    public AjaxResult getInfo(@PathVariable("logisticsParkId") Long logisticsParkId)
    {
        return success(wLogisticsParkInfoService.selectWLogisticsParkInfoByLogisticsParkId(logisticsParkId));
    }

    /**
     * 新增园区信息
     */
    @PreAuthorize("@ss.hasPermi('parks:park:add')")
    @Log(title = "园区信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WLogisticsParkInfo wLogisticsParkInfo)
    {
        wLogisticsParkInfo.setCreateBy(getNickName());
        return toAjax(wLogisticsParkInfoService.insertWLogisticsParkInfo(wLogisticsParkInfo));
    }

    /**
     * 修改园区信息
     */
    @PreAuthorize("@ss.hasPermi('parks:park:edit')")
    @Log(title = "园区信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WLogisticsParkInfo wLogisticsParkInfo)
    {
        wLogisticsParkInfo.setUpdateBy(getNickName());
        return toAjax(wLogisticsParkInfoService.updateWLogisticsParkInfo(wLogisticsParkInfo));
    }

    /**
     * 删除园区信息
     */
    @PreAuthorize("@ss.hasPermi('parks:park:remove')")
    @Log(title = "园区信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logisticsParkIds}")
    public AjaxResult remove(@PathVariable Long[] logisticsParkIds)
    {
        return toAjax(wLogisticsParkInfoService.deleteWLogisticsParkInfoByLogisticsParkIds(logisticsParkIds));
    }
}
